//
//  HomePageView.m
//  Project two framework
//
//  Created by 张峥 on 16/7/23.
//  Copyright © 2016年 张峥. All rights reserved.
//

#import "HomePageView.h"
#import "ZZConfig.h"
#import "LeftHomeCollectionViewCell.h"
#import "HomeTableViewCell.h"
#import "ZPZNetRequest+RecentProductsList.h"
#import "RightCollectionViewCell.h"
#import "ZPZNetRequest+CustomizationList.h"
#import "ZPZNetRequest+HotProductList.h"
#import "UIImageView+WebCache.h"
#import "DynamicView.h"
#import "ManageView.h"
#import "BankView.h"
#import "ChooeseView.h"
#import "PictureView.h"
#import "UIImageView+WebCache.h"
#define PHOTO_URL @"http://nmzh.rimiedu.com"
@interface HomePageView ()<UICollectionViewDelegate,UICollectionViewDataSource,UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UIImageView        *bottomView;
@property (nonatomic, strong) UICollectionView   *collectView;
@property (nonatomic, strong) UIImageView        *rightTopView;
@property (nonatomic, strong) UIImageView        *rightDownView;
@property (nonatomic, strong) UITableView        *tableView;
@property (nonatomic, strong) NSMutableArray     *TdataSource;
@property (nonatomic, strong) UICollectionView   *rightCollectView;
@property (nonatomic, strong) NSMutableArray     *rightDataSource;
@property (nonatomic, assign) BOOL               isFirst;
@property (nonatomic, strong) NSMutableArray     *downDataSource;
@property (nonatomic, strong) NSMutableArray     *photoDataSource;
@property (nonatomic, assign) NSInteger          index;
@property (nonatomic, strong) UIImageView        *currentImageView;
@property (nonatomic, strong) UIImageView        *nextImageView;
@property (nonatomic, strong) UILabel            *titleLabel;
@property (nonatomic, strong) UIImageView        *lineView;
@property (nonatomic, strong) UIImageView        *VerticalLineView;
@property (nonatomic, strong) UITableView        *investTableView;
@property (nonatomic, strong) DynamicView        *dynamicView;
@property (nonatomic, strong) ManageView         *manageView;
@property (nonatomic, strong) BankView           *bankView;
@property (nonatomic, strong) ChooeseView        *chooseView;
@property (nonatomic, strong) PictureView        *pictureView;
@property (nonatomic, strong) UILongPressGestureRecognizer *tap;
@property (nonatomic, strong) NSMutableArray     *array;
@end

@implementation HomePageView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self stepUI];
        [self loadDataSource];
        /** 接收通知 */
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detailAction:) name:@"123" object:nil];
    }
    return  self;
}


#pragma mark   ---  数据处理

- (void)loadDataSource{
    [ZPZNetRequest getRecentNewsListPageNum:@"1" pageSize:@"20" comletion:^(id object, BOOL success) {
        if (success) {
            _TdataSource = [NSMutableArray arrayWithArray:object[@"content"]];
            [_tableView reloadData];
        }
    }];
    [ZPZNetRequest getCustomizationDetailTotalNum:@"1" UserId:@"22" comletion:^(id object, BOOL success) {
        if (success) {
            _rightDataSource = [NSMutableArray arrayWithArray:object[@"content"]];
            [_rightCollectView reloadData];
        }

    }];
    [ZPZNetRequest getHotProductListTotalNum:@"1" UserId:@"22" comletion:^(id object, BOOL success) {
        if (success) {
            _downDataSource = [NSMutableArray arrayWithArray:object[@"content"]];
            [_collectView reloadData];
        }
    }];
    [ZPZNetRequest getRecentProductsListTotalNum:@"3" comletion:^(id object, BOOL success) {
        _photoDataSource = [NSMutableArray array];
        if (success) {
            _index = 0;
       _array = [NSMutableArray arrayWithArray:object[@"content"]];
            for (NSInteger i = 0 ; i < 3; i++) {
               NSDictionary *dic = _array[i];
                NSString *photo = [NSString stringWithFormat:@"%@%@",PHOTO_URL,dic[@"photo"]];
                [_photoDataSource addObject:photo];
            }
            [_currentImageView sd_setImageWithURL:[NSURL URLWithString:_photoDataSource[_index]]];
            _tap = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];
            //给当前的轮播图添加手势
            [_currentImageView addGestureRecognizer:_tap];
           //无限调用动画
            [NSTimer scheduledTimerWithTimeInterval:8 target:self selector:@selector(photoAnimation) userInfo:nil repeats:YES];

        }
    }];
}

#pragma mark -  实现通知的功能
- (void)detailAction:(NSNotification *)info
{
    NSInteger index = [info.userInfo[@"tag"] integerValue];
    
    NSDictionary *dic = self.downDataSource[index];
   
    NSString *name = dic[@"categoryName"];
    NSNumber *number = dic[@"id"];
    NSString *string = [NSString stringWithFormat:@"%@",number];
    if ([name isEqualToString:@"基金"]) {
        [ZPZNetRequest getHotProductDetailId:string comletion:^(id object, BOOL success) {
            if (success) {
                self.manageView = [ManageView showOtherView];
                self.manageView.fundLabel.text = [NSString stringWithFormat:@"基金代码: %@",object[@"content"][@"product_num"]];
               self.manageView.nameLabel.text = self.manageView.abbreviationLabel.text = [NSString stringWithFormat:@"基金简称: %@",object[@"content"][@"name"]];
                self.manageView.unitLabel.text = [NSString stringWithFormat:@"单位净值: %@",object[@"content"][@"asset_value"]];
                self.manageView.accumulativeLabel.text = [NSString stringWithFormat:@"累计净值: %@",object[@"content"][@"accumulative_value"]];
                self.manageView.deadlineLabel.text = [NSString stringWithFormat:@"截止日期: %@",object[@"content"][@"stop_time"]];
                
            } else {
                return ;
            }
                
        }];
        
    }
    if ([name isEqualToString:@"理财产品"]) {
        [ZPZNetRequest getHotProductDetailId:string comletion:^(id object, BOOL success) {
            if (success) {
                self.bankView = [BankView showOtherView];
                self.bankView.nameLabel.text = object[@"content"][@"name"];
                self.bankView.limit.text = [NSString stringWithFormat:@"投资期限(天): %@",object[@"content"][@"deadline"]];
                NSString *str = @"预期收益率(%): ";
                self.bankView.earnings.text = [NSString stringWithFormat:@"%@%@",str,object[@"content"][@"product_yield"]];
                self.bankView.money.text = [NSString stringWithFormat:@"起点金额(万元): %@",object[@"content"][@"start_sum"]];
                self.bankView.maturity.text = [NSString stringWithFormat:@"到期日: %@",object[@"content"][@"expire_time"]];
                /** 取出的 object[@"content"][@"iternetbank"] 是 number 类型 需要转换成字符串*/
                NSNumber *num = object[@"content"][@"iternetbank"];
                NSString *strin = [NSString stringWithFormat:@"%@",num];
                
                if ([strin isEqualToString:@"0"]) {
                    self.bankView.chinabank.text = [NSString stringWithFormat:@"是否支持网银: 不支持"];
                } else {
                    self.bankView.chinabank.text = [NSString stringWithFormat:@"是否支持网银: 支持"];
                }
                self.bankView.start.text = [NSString stringWithFormat:@"起售日: %@",object[@"content"][@"start_time"]];
                self.bankView.stop.text = [NSString stringWithFormat:@"停售日: %@",object[@"content"][@"stop_time"]];
                self.bankView.interest.text = [NSString stringWithFormat:@"起息日: %@",object[@"content"][@"carry_interest"]];
                self.bankView.lines.text = [NSString stringWithFormat:@"额度(亿元): %@",object[@"content"][@"product_limit"]];
            } else {
                return ;
            }
        }];
        
    }
    if ([name isEqualToString:@"出国留学金融服务"]) {
        [ZPZNetRequest getHotProductDetailId:string comletion:^(id object, BOOL success) {
            if (success) {
                self.chooseView = [ChooeseView showOtherView];
                self.chooseView.bottomView.hidden = YES;
                self.chooseView.nameLabel.text = self.chooseView.content.text = object[@"content"][@"abroadInfo"];
                
            } else {
                return ;
            }
        }];
        
        
    }
    if ([name isEqualToString:@"贵金属"]) {
        [ZPZNetRequest getHotProductDetailId:string comletion:^(id object, BOOL success) {
            if (success) {
                self.pictureView = [PictureView showOtherView];
                self.pictureView.nameLabel.text = object[@"content"][@"name"];
                NSString *matelStr = [NSString stringWithFormat:@"%@%@",PHOTO_URL,object[@"content"][@"metalsphoto"]];
                
                [self.pictureView.pictureImage sd_setImageWithURL:[self stringWithUrl:matelStr]];
                self.pictureView.condition.text = [NSString stringWithFormat:@"成色: %@",object[@"content"][@"quality"]];
                self.pictureView.circulation.text = [NSString stringWithFormat:@"发行量: %@",object[@"content"][@"circulation"]];
                self.pictureView.suppliers.text = [NSString stringWithFormat:@"供应商: %@",object[@"content"][@"supplierName"]];
                self.pictureView.size.text = [NSString stringWithFormat:@"规格: %@",object[@"content"][@"scale"]];
                self.pictureView.category.text = [NSString stringWithFormat:@"类别: %@",object[@"content"][@"typeName"]];
                self.pictureView.suitable.text = [NSString stringWithFormat:@"适宜人群(按年龄段): %@",object[@"content"][@"ageName"]];
                
            } else {
                return ;
            }
        }];
    }

}


- (NSURL *)stringWithUrl:(NSString*) string{
    NSURL *url = [NSURL URLWithString:string];
    return url;
}

#pragma mark - 长按手势
- (void)longPressAction:(UILongPressGestureRecognizer *)sender
{
    NSString *string = _array[_index][@"id"];
    if (sender.state == UIGestureRecognizerStateBegan) {
        [ZPZNetRequest getRecentProductDetailId:string comletion:^(id object, BOOL success) {
            if (success) {
                self.chooseView = [ChooeseView showOtherView];
                self.chooseView.nameLabel.text = object[@"content"][@"name"];
                self.chooseView.contents.text = self.chooseView.content.text = object[@"content"][@"info"];
                CGRect rect = [self.chooseView.contents.text boundingRectWithSize:CGSizeMake(200, 500) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil];
                self.chooseView.contents.frame = CGRectMake(0, 40, 200, rect.size.height);
            } else {
                return ;
            }
        }];
    }
}



#pragma mark   ---  UI

- (void)stepUI{
    UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:self.bounds];
    bgImageView.image = [UIImage imageNamed:@"大背景"];
    [self addSubview:bgImageView];
    
    
    _currentImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 630, 360)];
    _currentImageView.userInteractionEnabled = YES;
    _currentImageView.alpha = 1;
        [self addSubview:_currentImageView];
    
    _nextImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 630, 360)];
    _nextImageView.userInteractionEnabled = YES;
    _nextImageView.alpha = 0;
    [self addSubview:_nextImageView];
    
    [self addSubview:self.rightTopView];
    [self addSubview:self.rightDownView];
    
    _bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 390, 630, 280)];
    _bottomView.image = [UIImage imageNamed:@"底_14"];
    _bottomView.userInteractionEnabled = YES;
    [self addSubview:_bottomView];
    
    [_bottomView addSubview:self.collectView];
    [_collectView registerNib:[UINib nibWithNibName:@"LeftHomeCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomePageView"];

    UIImageView *hotImage = [[UIImageView alloc] initWithFrame:CGRectMake(550, 0, 80, 80)];
    hotImage.image = [UIImage imageNamed:@"hot_36"];
    [_bottomView addSubview:hotImage];
    
    [_rightTopView addSubview:self.tableView];
    [self.rightDownView addSubview:self.rightCollectView];
    [self.rightCollectView registerNib:[UINib nibWithNibName:@"RightCollectionViewCell"  bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"HomePageView"];
    
    UIImageView *newImage = [[UIImageView alloc] initWithFrame:CGRectMake(180, 0, 80, 80)];
    newImage.image = [UIImage imageNamed:@"最新动态_38"];
    [self.rightTopView addSubview:newImage];
    
    UIImageView *productImage = [[UIImageView alloc] initWithFrame:CGRectMake(180, 0, 80, 80)];
    productImage.image = [UIImage imageNamed:@"产品定制_39"];
    [self.rightDownView addSubview:productImage];
    [_bottomView addSubview:self.lineView];
    [_bottomView addSubview:self.VerticalLineView];
    
    
}


#pragma mark   ---  自定义方法
//轮播图动画逻辑
- (void)photoAnimation{
    if (_index == 3) {
        _index = 0;
    }
    NSInteger count = _index +1;
    if (_index == 2) {
        count = 0;
    }
  
    
    [_currentImageView sd_setImageWithURL:[NSURL URLWithString:_photoDataSource[_index]]];
    [_nextImageView sd_setImageWithURL:[NSURL URLWithString:_photoDataSource[count]]];
    _currentImageView.frame = CGRectMake(20, 20, 630, 360);
    _currentImageView.alpha = 1;

//    _currentImageView
    _nextImageView.alpha = 0;
    [UIView animateWithDuration:1 animations:^{
        _currentImageView.alpha = 0;
        _currentImageView.frame = CGRectMake(-1000, 20, 630, 360);
        _nextImageView.alpha = 1;
    }];
    [_nextImageView addGestureRecognizer:_tap];
        _index++;
}


#pragma mark   ---  协议
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    if (collectionView == _collectView) {
        return _downDataSource.count;

    }else{
        return _rightDataSource.count;
    }
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if (collectionView == _rightCollectView) {
        RightCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomePageView" forIndexPath:indexPath];
        NSDictionary *dic = _rightDataSource[indexPath.row];
        cell.titleLabel.text = dic[@"name"];
        if (indexPath.row > 4) {
            cell.bgImage.image = [UIImage imageNamed:@"理想之家·留学贷"];
        }else{
            cell.bgImage.image = [UIImage imageNamed:@"理财产品"];
        }
        return cell;
    }else{
    LeftHomeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomePageView" forIndexPath:indexPath];
        cell.backgroundColor = WHITE_C;
        cell.detailBtn.tag = indexPath.row;
        cell.layer.cornerRadius = 265/20;
        cell.clipsToBounds = YES;
        NSDictionary *dic = _downDataSource[indexPath.row];
        cell.titleLabel.text = dic[@"name"];
        cell.timeLabel.text = dic[@"published"];
        NSString *name = dic[@"categoryName"];
        if ([name isEqualToString:@"基金"]) {
            cell.titleImage.image = [UIImage imageNamed:@"基金1"];
        }
        if ([name isEqualToString:@"理财产品"]) {
            cell.titleImage.image = [UIImage imageNamed:@"理财产品1"];
        }
        if ([name isEqualToString:@"出国留学金融服务"]) {
            cell.titleImage.image = [UIImage imageNamed:@"理想之家·留学贷"];
        }
        if ([name isEqualToString:@"贵金属"]) {
            cell.titleImage.image = [UIImage imageNamed:@"贵金属"];
        }
        return cell;
    }
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (collectionView == _rightCollectView) {
        NSString *name = _rightDataSource[indexPath.row][@"categoryName"];
        NSNumber *number = _rightDataSource[indexPath.row][@"id"];
        NSLog(@"ghjbnfndjhkfbdjfshd++_+==%@",name);
        NSLog(@"ghjbnfndjhkfbdjfshd++_+==%@",number);
        NSString *string = [NSString stringWithFormat:@"%@",number];
        if ([name isEqualToString:@"基金"]) {
            [ZPZNetRequest getCustomizationDetailId:string comletion:^(id object, BOOL success) {
                if (success) {
                    self.manageView = [ManageView showOtherView];
                    self.manageView.fundLabel.text = [NSString stringWithFormat:@"基金代码: %@",object[@"content"][@"product"][@"product_num"]];
                    self.manageView.nameLabel.text = self.manageView.abbreviationLabel.text = [NSString stringWithFormat:@"基金简称: %@",object[@"content"][@"product"][@"name"]];
                    self.manageView.unitLabel.text = [NSString stringWithFormat:@"单位净值: %@",object[@"content"][@"product"][@"asset_value"]];
                    self.manageView.accumulativeLabel.text = [NSString stringWithFormat:@"累计净值: %@",object[@"content"][@"product"][@"accumulative_value"]];
                    self.manageView.deadlineLabel.text = [NSString stringWithFormat:@"截止日期: %@",object[@"content"][@"product"][@"stop_time"]];
                    
                } else {
                    return ;
                }
                
            }];
            
        }
        if ([name isEqualToString:@"理财产品"]) {
            [ZPZNetRequest getCustomizationDetailId:string comletion:^(id object, BOOL success) {
                if (success) {
                    self.bankView = [BankView showOtherView];
                    self.bankView.nameLabel.text = object[@"content"][@"product"][@"name"];
                    self.bankView.limit.text = [NSString stringWithFormat:@"投资期限(天): %@",object[@"content"][@"product"][@"deadline"]];
                    NSString *str = @"预期收益率(%): ";
                    self.bankView.earnings.text = [NSString stringWithFormat:@"%@%@",str,object[@"content"][@"product"][@"product_yield"]];
                    self.bankView.money.text = [NSString stringWithFormat:@"起点金额(万元): %@",object[@"content"][@"product"][@"start_sum"]];
                    self.bankView.maturity.text = [NSString stringWithFormat:@"到期日: %@",object[@"content"][@"product"][@"expire_time"]];
                    /** 取出的 object[@"content"][@"iternetbank"] 是 number 类型 需要转换成字符串*/
                    NSNumber *num = object[@"content"][@"product"][@"iternetbank"];
                    NSString *strin = [NSString stringWithFormat:@"%@",num];
                    
                    if ([strin isEqualToString:@"0"]) {
                        self.bankView.chinabank.text = [NSString stringWithFormat:@"是否支持网银: 不支持"];
                    } else {
                        self.bankView.chinabank.text = [NSString stringWithFormat:@"是否支持网银: 支持"];
                    }
                    self.bankView.start.text = [NSString stringWithFormat:@"起售日: %@",object[@"content"][@"product"][@"start_time"]];
                    self.bankView.stop.text = [NSString stringWithFormat:@"停售日: %@",object[@"content"][@"product"][@"stop_time"]];
                    self.bankView.interest.text = [NSString stringWithFormat:@"起息日: %@",object[@"content"][@"product"][@"carry_interest"]];
                    self.bankView.lines.text = [NSString stringWithFormat:@"额度(亿元): %@",object[@"content"][@"product"][@"product_limit"]];
                } else {
                    return ;
                }
            }];
        }
        if ([name isEqualToString:@"出国留学金融服务"]) {
            [ZPZNetRequest getCustomizationDetailId:string comletion:^(id object, BOOL success) {
                    if (success) {
                        self.chooseView = [ChooeseView showOtherView];
                        self.chooseView.bottomView.hidden = YES;
                        self.chooseView.nameLabel.text = self.chooseView.content.text = object[@"content"][@"product"][@"abroadInfo"];
                        
                    } else {
                        return ;
                    }
                }];
            
        }
        if ([name isEqualToString:@"贵金属"]) {
            [ZPZNetRequest getCustomizationDetailId:string comletion:^(id object, BOOL success) {
                if (success) {
                    NSLog(@"tryuiiouhuib-=-==%@",object);
                    self.pictureView = [PictureView showOtherView];
                    self.pictureView.nameLabel.text = object[@"content"][@"product"][@"name"];
                    NSString *matelStr = [NSString stringWithFormat:@"%@%@",PHOTO_URL,object[@"content"][@"product"][@"metalsphoto"]];
                    
                    [self.pictureView.pictureImage sd_setImageWithURL:[self stringWithUrl:matelStr]];
                    self.pictureView.condition.text = [NSString stringWithFormat:@"成色: %@",object[@"content"][@"product"][@"quality"]];
                    self.pictureView.circulation.text = [NSString stringWithFormat:@"发行量: %@",object[@"content"][@"product"][@"circulation"]];
                    self.pictureView.suppliers.text = [NSString stringWithFormat:@"供应商: %@",object[@"content"][@"product"][@"supplierName"]];
                    self.pictureView.size.text = [NSString stringWithFormat:@"规格: %@",object[@"content"][@"product"][@"scale"]];
                    self.pictureView.category.text = [NSString stringWithFormat:@"类别: %@",object[@"content"][@"product"][@"typeName"]];
                    self.pictureView.suitable.text = [NSString stringWithFormat:@"适宜人群(按年龄段): %@",object[@"content"][@"product"][@"ageName"]];
                    
                } else {
                    return ;
                }
            }];
        }
    }
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _TdataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static  NSString  *cellIndenfier = @"HomePageView";
    HomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndenfier];
    if (!cell) {
        cell = [[HomeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndenfier];
        NSDictionary *dic = _TdataSource[indexPath.row];
        NSString *title = [NSString stringWithFormat:@"·%@",dic[@"title"]];
        cell.titleLabel.text = title;
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    self.dynamicView = [DynamicView showOtherView];
    NSNumber *number = _TdataSource[indexPath.row][@"id"];
    
    NSString *string = [NSString stringWithFormat:@"%@",number];
    [ZPZNetRequest getRecentNewsDetailTotalId:string comletion:^(id object, BOOL success) {
        if (success) {
            _dynamicView.nameLabel.text = object[@"content"][@"title"];
           _dynamicView.content.text = object[@"content"][@"content"];
    
            CGRect rect = [_dynamicView.content.text boundingRectWithSize:CGSizeMake(630, 500) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil];
            _dynamicView.content.frame = CGRectMake(50, 100, 650, rect.size.height);
        } else {
            return ;
        }
    }];
    
    
}


#pragma mark   ---  懒加载
- (UICollectionView *)collectView{
    if (!_collectView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(250, 90);
        layout.minimumLineSpacing = 60;
        layout.minimumInteritemSpacing = 20;
        
        //设置滚动方向
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        _collectView = [[UICollectionView alloc] initWithFrame:CGRectMake(30, 30, 610, 200) collectionViewLayout:layout];
        _collectView.showsHorizontalScrollIndicator = NO;
        _collectView.backgroundColor = [UIColor clearColor];
        _collectView.delegate = self;
        _collectView.contentInset = UIEdgeInsetsMake(0, 0, 0, 50);
        _collectView.pagingEnabled = YES;
        _collectView.dataSource = self;
    }
    return _collectView;
}

- (UIImageView *)rightTopView{
    if (!_rightTopView) {
        _rightTopView = [[UIImageView alloc] initWithFrame:CGRectMake(670, 20, 260, 360)];
        _rightTopView.userInteractionEnabled = YES;
        _rightTopView.image = [UIImage imageNamed:@"最新动态-底_09"];
    }
    return  _rightTopView;
}

- (UIImageView *)rightDownView{
    if (!_rightDownView) {
        _rightDownView = [[UIImageView alloc] initWithFrame:CGRectMake(670, 390, 260, 280)];
        _rightDownView.userInteractionEnabled = YES;
        _rightDownView.image = [UIImage imageNamed:@"产品定制-底_14"];
    }
    return  _rightDownView;
}


- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 10, 240, 200)];
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.rowHeight = 40;
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return  _tableView;
}

- (UICollectionView *)rightCollectView{
    if (!_rightCollectView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(110, 90);
        layout.minimumLineSpacing = 20;
        layout.minimumInteritemSpacing = 0;
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        //设置滚动方向
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        _rightCollectView = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 40, 260, 190) collectionViewLayout:layout];
        _rightCollectView.showsHorizontalScrollIndicator = NO;
        _rightCollectView.backgroundColor = [UIColor clearColor];
        _rightCollectView.delegate = self;
        _rightCollectView.contentInset = UIEdgeInsetsMake(0, 0, 0, 20);
        _rightCollectView.pagingEnabled = YES;
        _rightCollectView.dataSource = self;
    }
    return _rightCollectView;
}

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.center = self.center;
        _titleLabel.bounds = CGRectMake(0, 0, 200, 80);
        _titleLabel.alpha = 0;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.backgroundColor = [UIColor redColor];
        _titleLabel.font = [UIFont systemFontOfSize:18 weight:4];
    }
    return _titleLabel;
}


- (UIImageView *)lineView{
    if (!_lineView) {
        _lineView = [[UIImageView alloc] init];
        _lineView.center = CGPointMake(CGRectGetMidX(_bottomView.bounds), CGRectGetMidY(_bottomView.bounds)-10);
        _lineView.bounds = CGRectMake(0, 0, 600, 3);
        _lineView.image = [UIImage imageNamed:@"xian_08"];
    }
    return _lineView;
}

- (UIImageView *)VerticalLineView{
    if (!_VerticalLineView) {
        _VerticalLineView = [[UIImageView alloc] init];
        _VerticalLineView.center = CGPointMake(CGRectGetMidX(_bottomView.bounds), CGRectGetMidY(_bottomView.bounds)-10);
        _VerticalLineView.bounds = CGRectMake(0, 0, 3, 200);
        _VerticalLineView.image = [UIImage imageNamed:@"line_05"];
    }
    return _VerticalLineView;

}



@end
